package com.mjlf.test_shiro.service;

import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: PermissionService
 * @Author: majun
 * @CreateDate: 2018/10/17 16:38
 * @Version: 1.0
 * @Description: TODO
 */

@Service
public class PermissionService {

    public List<String> getPermissions(){
        List<String> permissinos = new ArrayList<>();
        permissinos.add("write");
        permissinos.add("read");
        permissinos.add("other");

        return permissinos;
    }

    public List<String> getPermissions(String username){
        List<String> permissinos = new ArrayList<>();
        switch (username){
            case "admin":
                permissinos.add("write");
                permissinos.add("read");
                permissinos.add("other");
                break;
            case "guest":
                permissinos.add("read");
                permissinos.add("other");
                break;
            case "other":
                permissinos.add("other");
        }
        return permissinos;
    }
}
